//
// Created by Gorun on 2022/5/2.
//

#include "Number.h"
#include <string>

Number::Number(double number) {
    this->number=number;
}

double Number::getNumber() const {
    return number;
}

void Number::setNumber(double num) {
    this->number=num;
}

std::string Number::toString() const {
    //1.1->"1.1" and 1.0->"1"
    std::string str=std::to_string(number);
    bool findDot = str.find('.')!=std::string::npos;
    if (findDot) {
        while(*(str.cend()-1)=='0')
            str.pop_back();
        if (*(str.cend()-1)=='.')
            str.pop_back();//pop the '.' if it's a Integer
    }
    return str;
}